tree.io.rpc = {}
###
Proxy for rpc server methods.


events: ['error-occured']

This class is an abstract class. Subclasses must override:
    
    string create_request(string name, params[])
    
    object parse_response(string data)

###

class tree.io.rpc.Proxy extends tree.BaseObject
    
    constructor: (@url, content_type) ->
        super
        @content_type = content_type
        @content_type ?= tree.io.ajax.DATA_FORMAT.plain
        
    parse_response: (data) ->
        throw new 'method create_request not implemented'
        
    create_request: (data) ->
        throw new 'method create_request not implemented'
        
        
    call_method: (name, params) ->
        request = @create_request name, params
        response  = tree.io.ajax.xhr @url, {async: false, type: tree.io.ajax.REQUEST_METHODS.POST, raw_data: request }
        @parse_response response

